package com.jdjw.modules.busassetarchives.service.impl;

import com.jdjw.common.ResponseResult;
import com.jdjw.modules.busassetarchives.entity.BusAssetArchives;
import com.jdjw.modules.busassetarchives.mapper.BusAssetArchivesMapper;
import com.jdjw.modules.busassetarchives.service.BusAssetArchivesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.ws.Response;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * bus_asset_archives 服务实现类
 * </p>
 *
 * @author fq
 * @since 2021-06-25
 */
@Service
public class BusAssetArchivesServiceImpl extends ServiceImpl<BusAssetArchivesMapper, BusAssetArchives> implements BusAssetArchivesService {

    @Autowired
    private BusAssetArchivesMapper busAssetArchivesMapper;

    @Override
    public ResponseResult queryAll(BusAssetArchives busAssetArchives) {
        List<BusAssetArchives> list = busAssetArchivesMapper.queryAll(busAssetArchives);
        ResponseResult responseResult=new ResponseResult();
        if(!StringUtils.isEmpty(list)){
            responseResult.setCode(200);
            responseResult.setMsg("操作成功");
            responseResult.setData(list);
        }else{
            responseResult.setCode(500);
            responseResult.setMsg("操作失败");
            responseResult.setData(null);
        }
        return responseResult;
    }

    @Override
    public ResponseResult sqlEnit(String sql) {
        ResponseResult rr=new ResponseResult();
        boolean b = busAssetArchivesMapper.sqlEdit(sql);
        if (b){
           rr.setMsg("编辑成功");
           rr.setCode(200);
        }else{
            rr.setMsg("编辑失败");
            rr.setCode(500);
        }
        return rr;
    }

    public boolean updatestatus(Map<String, Object> map){
        return super.baseMapper.updatestatus(map);
    }
}
